import request from "@/utils/request";
import * as api from "./request-url";
import { getParams,getCookie } from "@/utils/utils";

//用户信息
export async function getUserInfo({ }) {
  return request(`${api.getUserInfo}?${getParams({})}`);
}
//用户
export async function getOtherUserInfoList({userId,userName}) {
  return request(`${api.getOtherUserInfoList}?${getParams({userId,userName})}`);
}
//首页--热词
export async function hotWord({ }) {
  return request(`${api.hotWord}?${getParams({})}`);
}
//首页--特色资源
export async function scientific({ }) {
  return request(`${api.scientific}`, {
    method: "POST",
    body: {}
  });
}
export async function getUserStatus({ }) {
  return request(`${api.getUserStatus}?${getParams({})}`);
}
//首页--特色资源--展示部分资源、首页--资源统计-热点词云、首页--资源统计-学科分类、首页--资源统计
export async function getScientificData({ }) {
  return request(`${api.getScientificData}`, {
    method: "POST",
    body: {}
  });
}
// 首页--资源排行
export async function resourceRanking({ pageSize, pageNum }) {
  return request(`${api.resourceRanking}?${getParams({ pageSize, pageNum })}`);
}
//首页--专题
export async function getSpecial({ }) {
  return request(`${api.getSpecial}?${getParams({})}`);
}
//首页--公告通知
export async function getAnnounceList({ }) {
  return request(`${api.getAnnounceList}?${getParams({})}`);
}
//首页--累计访问人数
export async function headerInformationNum({ }) {
  return request(`${api.headerInformationNum}?${getParams({})}`);
}
//收藏列表
export async function getCollectionList({
  userId,
  keyword,
  startTime,
  endTime,
  pageSize,
  pageNum
}) {
  return request(
    `${api.getCollectionList}?pageSize=${pageSize}&pageNum=${pageNum}`,
    {
      method: "POST",
      body: {
        userId,
        keyword,
        startTime,
        endTime
      }
    }
  );
}
//收藏取消
export async function deleteCollection({ resourceId, userId }) {
  return request(`${api.deleteCollection}`, {
    method: "POST",
    body: {
      resourceId,
      userId
    }
  });
}
//分享添加
export async function addShare({
  userId,
  resourceType,
  resourceId,
  personId,
  startTime,
  endTime,
  text
}) {
  return request(`${api.addShare}`, {
    method: "POST",
    body: {
      userId,
      resourceType,
      resourceId,
      personId,
      startTime,
      endTime,
      text
    }
  });
}

//分享删除
export async function deleteShare({ userId, shareType, id }) {
  return request(`${api.deleteShare}`, {
    method: "POST",
    body: {
      userId,
      shareType,
      id
    }
  });
}
//标准列表
export async function getStandardList({
  pageSize,
  currentPage,
  name,
  writeUnit
}) {
  return request(
    `${api.getStandardList}?${getParams({
      pageSize,
      currentPage,
      name,
      writeUnit
    })}`
  );
}
// //标准详情id
// export async function getStandardInfo({ id }) {
//   return request(`${api.getStandardInfo}?${getParams({ id })}`);
// }
//标准描述增加
export async function createStandard({
  author,
  chinaTypeNum,
  content,
  deft,
  effectDate,
  endTime,
  executeUnit,
  fileUrl,
  nationalTypeNum,
  num,
  releaseTime,
  subject,
  subtitle,
  title,
  type,
  unit,
  writeSchool,
  writeUnit,
  id
}) {
  return request(`${api.createStandard}`, {
    method: "POST",
    body: {
      author,
      chinaTypeNum,
      content,
      deft,
      effectDate,
      endTime,
      executeUnit,
      fileUrl,
      nationalTypeNum,
      num,
      releaseTime,
      subject,
      subtitle,
      title,
      type,
      unit,
      writeSchool,
      writeUnit,
      id
    }
  });
}
//标准描述删除
export async function deleteStandard({ id }) {
  return request(`${api.deleteStandard}?${getParams({ id })}`);
}
//标准元数据列表
export async function getBasicFieldInfoList({ id }) {
  return request(`${api.getBasicFieldInfoList}?${getParams({ id })}`);
}
//标准排行
export async function getStandDetailInfoRank({ num }) {
  return request(`${api.getStandDetailInfoRank}/${num}`);
}
//标准关联
export async function getAssociationInfo({ query }) {
  return request(`${api.getAssociationInfo}?${getParams({ query })}`);
}
//标准元数据增加/编辑
export async function saveBasicFieldInfo({
  id,
  stId,
  limits,
  name,
  sort,
  type
}) {
  return request(`${api.saveBasicFieldInfo}`, {
    method: "POST",
    body: {
      id,
      stId,
      limits,
      name,
      sort,
      type
    }
  });
}

//科研软件
//获取分类树
export async function getDirs() {
  return request(`${api.getDirs}`);
}
//分类增加编辑
export async function saveDir({
  id,
  name,
  type,
  mark,
  createTime,
  sort,
  parentCode
}) {
  return request(`${api.saveDir}`, {
    method: "POST",
    body: {
      id,
      name,
      type,
      mark,
      createTime,
      sort,
      parentCode
    }
  });
}
//分类目录删除
export async function deleteDir({ key }) {
  return request(`${api.deleteDir}?${getParams({ key })}`);
}
//科研软件列表
export async function getKnowledgeByPage({
  pageSize,
  currentPage,
  author,
  startTime,
  endTime,
  type
}) {
  return request(
    `${api.getKnowledgeByPage}?${getParams({
      pageSize,
      currentPage,
      author,
      startTime,
      endTime,
      type
    })}`
  );
}
//科研软件新增  编辑
export async function saveKnowledge({
  addTime,
  author,
  belongUnit,
  content,
  desc,
  downloadNum,
  id,
  imgUrls,
  keys,
  releaseTime,
  source,
  subtitle,
  tile,
  type,
  visitNum,
  behaviour,
  attachment
}) {
  return request(`${api.saveKnowledge}`, {
    method: "POST",
    body: {
      addTime,
      author,
      belongUnit,
      content,
      desc,
      downloadNum,
      id,
      imgUrls,
      keys,
      releaseTime,
      source,
      subtitle,
      tile,
      type,
      visitNum,
      behaviour,
      attachment
    }
  });
}
//科研软件删除
export async function deleteKnowledge({ id }) {
  return request(`${api.deleteKnowledge}?${getParams({ id })}`);
}
//科研软件详情
export async function getKnowledgeInfo({ id }) {
  return request(`${api.getKnowledgeInfo}?${getParams({ id })}`);
}

///专题
//专题列表
export async function getTopicByPage({
  pageSize,
  currentPage,
  name,
  startTime,
  endTime
}) {
  return request(
    `${api.getTopicByPage}?${getParams({
      pageSize,
      currentPage,
      name,
      startTime,
      endTime
    })}`
  );
}
//专题新增  编辑
export async function saveTopic({
  cover,
  id,
  introduction,
  knowledgeList,
  logo,
  name,
  resourceList,
  tags
}) {
  return request(`${api.saveTopic}`, {
    method: "POST",
    body: {
      cover,
      id,
      introduction,
      knowledgeList,
      logo,
      name,
      resourceList,
      tags
    }
  });
}
//专题删除
export async function deleteTopic({ id }) {
  return request(`${api.deleteTopic}?${getParams({ id })}`);
}
//专题详情
export async function getTopicInfo({ id }) {
  return request(`${api.getTopicInfo}?${getParams({ id })}`);
}

//文件上传
export async function upload({ file }) {
  return request(`${api.upload}`, {
    method: "POST",
    body: {
      file
    }
  });
}
//资源统计
export async function queryStatistics({ type }) {
  return request(`${api.queryStatistics}?${getParams({ type })}`);
}
//资源排行

export async function queryRanking({ type }) {
  return request(`${api.queryRanking}?${getParams({ type })}`);
}
//数据资产--热词
export async function queryHotWord({ word }) {
  return request(`${api.queryHotWord}?${getParams({ word })}`);
}
//数据资产管理列表、资源检索列表
export async function queryDataAsset({
  userId,
  text,
  startTime,
  endTime,
  subjects,
  sources,
  format,
  scope,
  pageNum,
  pageSize,
  sort
}) {
  return request(`${api.queryDataAsset}`, {
    method: "POST",
    body: {
      userId,
      text,
      startTime,
      endTime,
      subjects,
      sources,
      format,
      scope,
      pageNum,
      pageSize,
      sort
    }
  });
}
//数据资产，标准分类依据
export async function queryCategory({ pid }) {
  return request(`${api.queryCategory}?${getParams({ pid })}`);
}
//数据资产详情查看

export async function queryDataDetail({ id }) {
  return request(`${api.queryDataDetail}?${getParams({ id })}`);
}
//收藏添加
export async function addCollection({ userId, resourceType, resourceId }) {
  return request(`${api.addCollection}`, {
    method: "POST",
    body: {
      userId,
      resourceType,
      resourceId
    }
  });
}

//数据关联接口
export async function queryAssociation({ id }) {
  return request(`${api.queryAssociation}?${getParams({ id })}`);
}
//意见反馈
export async function insert(params = {}) {
  return request(`${api.insert}`, {
    method: "POST",
    body: {
      opinionInfo: params.opinionInfo,
      title: params.title
    },
    headers: {
      "Content-Type": "application/json;charset=utf-8"
    }
  });
}

//帮助目录
export async function getHelp({ }) {
  return request(`${api.getHelp}`);
}

//帮助文档内容
export async function getHelpInfo({ id }) {
  return request(`${api.getHelpInfo}?${getParams({ id })}`);
}

//帮助文档分页
export async function getHelpByPage({
  pageSize,
  pageNum,
  title,
  content,
  catalog,
  parentId,
  ids
}) {
  return request(
    `${api.getHelpByPage}?${getParams({
      pageSize,
      pageNum,
      title,
      content,
      catalog,
      parentId,
      ids
    })}`
  );
}
//获取目录下的文章
export async function getHelpBycatalogId({ id }) {
  return request(`${api.getHelpBycatalogId}`, {
    method: "POST",
    body: {
      id
    }
  });
}

//科研软件分页
export async function getScientificByPage({
  pageSize,
  pageNum,
  title,
  keys,
  desc,
  type,
  orderBy
}) {
  return request(
    `${api.getScientificByPage}?${getParams({
      pageSize,
      pageNum,
      title,
      keys,
      desc,
      type,
      orderBy
    })}`
  );
}

//科研软件详情
export async function getScientificInfo({ id }) {
  return request(
    `${api.getScientificInfo}?${getParams({
      id
    })}`
  );
}

//科研软件下载
export async function download({ path }) {
  return request(
    `${api.download}?${getParams({
      path
    })}`
  );
}

//科研附件下载
export async function downloadN({ path }) { 
  return request(`${api.downloadN}?${getParams({path})}`, {
    method: "POST",
    body: {
    }
  });
}

//科研软件下载量
export async function Downloads({ id }) {
  return request(
    `${api.Downloads}?${getParams({
      id
    })}`
  );
}

//科研软件分类
export async function getScientificDirs({ type }) {
  return request(
    `${api.getScientificDirs}?${getParams({
      type
    })}`
  );
}

//科研软件数据关联
export async function selectBykeys({ id, keys, title }) {
  return request(
    `${api.selectBykeys}?${getParams({
      id, keys, title
    })}`
  );
}

//科研软件最新发布资源
export async function selectByCreateTime({ pageSize, pageNum }) {
  return request(
    `${api.selectByCreateTime}?${getParams({
      pageSize,
      pageNum
    })}`
  );
}

//专题列表
export async function selectByPage({ pageSize, pageNum, name, timeCount }) {
  return request(
    `${api.selectByPage}?${getParams({
      pageSize,
      pageNum,
      name,
      timeCount
    })}`
  );
}
//专题详情
export async function selectTopicMessageById({ id }) {
  return request(
    `${api.selectTopicMessageById}?${getParams({
      id
    })}`
  );
}
//标准详细信息列表
export async function getStandDetailInfoListByPage({
  pageSize,
  currentPage,
  query,
  id
}) {
  return request(
    `${api.getStandDetailInfoListByPage}?${getParams({
      pageSize,
      currentPage,
      query,
      id
    })}`
  );
}
//标准列表
export async function getStandardInfoByPage({
  pageSize,
  currentPage,
  subject,
  query,
  type,
  visitNum,
  behaviour,
  releaseTime
}) {
  return request(
    `${api.getStandardInfoByPage}?${getParams({
      pageSize,
      currentPage,
      subject,
      query,
      type,
      visitNum,
      behaviour,
      releaseTime
    })}`
  );
}
//标准详情
export async function getStandardInfo({ id }) {
  return request(
    `${api.getStandardInfo}?${getParams({
      id
    })}`
  );
}
//字典类型获取
export async function getByType({ type }) {
  return request(
    `${api.getByType}?${getParams({
      type
    })}`
  );
}
